<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="./ajax封装.js"></script>
    <script>
        /*
            跨域：协议，域名，端口号只要有一个不一样就产生跨域问题
            解决方式：
                    1.手动解决
                    2.依赖第三方插件解决
        */

        async function fn() {
            let [err, res] = await myajax(type)
        }
        fn()

        $.ajax({
            type: 'get',
            url: 'http://localhost:3000/index',
            success(res) {
                console.log(res);
            }
        })
        $.ajax({
            type: 'post',
            url: 'http://localhost:3000/index',
            success(res) {
                console.log(res);
            }
        })
        $.ajax({
            type: 'put',
            url: 'http://localhost:3000/index',
            success(res) {
                console.log(res);
            }
        })
        $.ajax({
            type: 'delete',
            url: 'http://localhost:3000/index',
            success(res) {
                console.log(res);
            }
        })
    </script>
</body>

</html>